import _ from 'lodash'

// 获得语言
export const locale = state => state.locale

// 刷新变量
export const reload = state => state.reload

// 表单构造
export const formData = state => state.formData

// 高亮项
export const selector = state => state.selector

// 高亮行
export const selectedRow = state => {
    if (_.isEmpty(state.selector.rowGid)) return null
    return _.find(state.formData.rows, { rowGid: state.selector.rowGid })
}

// 高亮控件
export const selectedUnit = state => {
    if (_.isEmpty(state.selector.rowGid)) return null
    let row = _.find(state.formData.rows, { rowGid: state.selector.rowGid })
    if (_.isEmpty(row)) return null
    return _.find(row.units, { unitGid: state.selector.unitGid })
}

// 当前是否高亮行
export const isRowSelector = state => !_.isEmpty(state.selector.rowGid) && _.isEmpty(state.selector.unitGid)

// 当前是否高亮控件
export const isUnitSelector = state => !_.isEmpty(state.selector.rowGid) && !_.isEmpty(state.selector.unitGid)

// 剪贴板
export const clipboard = state => state.clipboard
